home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 17
/
CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso
/
CUCD
/
Graphics
/
RTGmaster
/
demos
/
network
/
TCPServ.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-09-26
|
2KB
|
72 lines
#include <clib/rtgextra_protos.h>
#include <pragmas/rtgextra_pragmas.h>
#include <clib/exec_protos.h>
#include <pragmas/exec_pragmas.h>
#include <stdio.h>
#include <rtgmaster/rtgtcpip.h>
#include <string.h>
struct Library *SocketBase=0;
struct Library *RTGExtraBase=0;
void main()
{
if (RTGMasterBase=OpenLibrary("rtgextra.library",0))
{
if (SocketBase=OpenLibrary("bsdsocket.library",0))
{
struct RTG_Socket *rs;
struct RTG_Socket *rs2;
struct RTG_Socket *msgsock;
struct RTG_Buff in_buffer;
struct RTG_Buff out_buffer;
long arg=1;
char buf[1024];
int f,rval;
for (f=0;f<9;f++)
{
in_buffer.num[f]=-1;
out_buffer.num[f]=-1;
}
in_buffer.in_size=21;
out_buffer.out_size=25;
rs=OpenServer(SocketBase,3050,SOCK_STREAM,0);
RtgIoctl(SocketBase,rs,&arg);
while(1)
{
rs2=rs->list;
if (rs->num>1)
for (f=0;f<((rs->num)-1);f++)
{
strcpy(out_buffer.sock[f],"Message from the Server!");
out_buffer.num[f]=rs2->s;
rs2=rs2->list;
}
if (rs->num>1)
for (f=0;f<((rs->num)-1);f++)
{
if (in_buffer.num[f]!=-1) printf("%s %i\n",in_buffer.sock[f],in_buffer.num[f]);
}
for (f=0;f<9;f++)
{
in_buffer.num[f]=-1;
}
if (RunServer(SocketBase,rs,&in_buffer,&out_buffer,9))
{
int f=1;
struct RTG_Socket *tsock;
for(tsock=rs;tsock->list;tsock=tsock->list)
{
printf("Socket Nr. : %i ist %i\n",f,(tsock->list)->s);
f++;
}
}
}
if (SocketBase) CloseLibrary(SocketBase);
if (RTGExtraBase) CloseLibrary(RTGExtraBase);
}
}
}